﻿<Window
    x:Class="Gumini.JulaDB.Navigator.Views.ConnectionWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Connect to database" Height="300" Width="550">
    
    <DockPanel
        Margin="15"
        LastChildFill="False">
        
        <StackPanel
            DockPanel.Dock="Bottom"
            HorizontalAlignment="Right"
            Orientation="Horizontal">
            
            <StackPanel.Resources>
                <Style TargetType="Button" BasedOn="{StaticResource {x:Static ToolBar.ButtonStyleKey}}">
                    <Setter Property="Height" Value="30" />
                    <Setter Property="Width" Value="100" />
                    <Setter Property="BorderThickness" Value="1" />
                    <Setter Property="BorderBrush" Value="Gray" />
                </Style>
            </StackPanel.Resources>
            
            <Button
                Content="Connect"
                Command="{Binding ConnectCommand}" />
            
            <Button
                Content="Cancel"
                Command="{Binding CancelCommand}" />
            
        </StackPanel>

        <GroupBox
            DockPanel.Dock="Top"
            Header="Connection details">

            <Grid Margin="15">
            
                <Grid.RowDefinitions>
                    <RowDefinition Height="30" />
                    <RowDefinition Height="30" />
                    <RowDefinition Height="30" />
                    <RowDefinition Height="30" />
                </Grid.RowDefinitions>
            
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>

                <Label
                    Grid.Column="0" Grid.Row="0"
                    Content="Database type:" />
            
                <Label
                    Grid.Column="0" Grid.Row="2"
                    IsEnabled="{Binding Path=IsInMemory, Converter={StaticResource InverseBooleanConverter}}"
                    Content="File path:" />
            
                <RadioButton
                    Grid.Column="1" Grid.Row="0"
                    Content="In-memory"
                    IsChecked="{Binding Path=IsInMemory}" />

                <RadioButton
                    Grid.Column="1" Grid.Row="1"
                    Content="File"
                    IsChecked="{Binding Path=IsInMemory, Converter={StaticResource InverseBooleanConverter}}" />

                <TextBox
                    Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="2"
                    VerticalAlignment="Top"
                    IsEnabled="{Binding Path=IsInMemory, Converter={StaticResource InverseBooleanConverter}}"
                    Text="{Binding Path=FilePath, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                
                <StackPanel
                    Grid.Column="1" Grid.Row="2"
                    Orientation="Horizontal"
                    HorizontalAlignment="Right">

                    <Button
                        Width="60"
                        Content="Clear"
                        Command="{Binding ClearCommand}" />

                    <Button
                        Width="60"
                        Content="Browse..."
                        Command="{Binding BrowseCommand}" />

                </StackPanel>
            
            </Grid>

        </GroupBox>

    </DockPanel>
    
</Window>
